package com.example.websocketdemo.controller;

import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.example.websocketdemo.config.WebSocketTest;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

@RestController
@RequestMapping("/tankField")
public class RealTimeTankFarmDataController {

    @GetMapping("/message")
    public void t(HttpServletResponse response) throws IOException {
        response.setHeader("Access-Control-Allow-Origin", "*");
//        JSONObject jsonObject = new JSONObject();
//        JSONObject json = new JSONObject();
//        JSONObject xinxi = new JSONObject();
//        JSONObject xinxi1 = new JSONObject();
//        JSONObject xinxi2 = new JSONObject();
//        JSONObject xinxi3 = new JSONObject();
//        JSONObject xinxi4 = new JSONObject();
//        JSONObject xinxi5 = new JSONObject();
//
//        JSONArray Array = new JSONArray();
//        jsonObject.put("instruction","updatepoi");
//        json.put("updatetype","reset");
//        json.put("poigroup","tankField");
//        json.put("poitype","message");
//
//        xinxi.put("罐的形状类型","内浮顶");
//        xinxi.put("设备名称","T101汽油罐");
//        xinxi.put("温度类型","常温罐");
//        xinxi.put("压力类型","常压罐");
//        xinxi.put("设计压力","1");
//        xinxi.put("设计温度低限","0");
//        xinxi.put("设计温度高限","100");
//        xinxi.put("最高工作压力","1");
//        xinxi.put("储存介质","汽油");
//        xinxi.put("介质形态","液态");
//        xinxi.put("LT1011油罐液位","2.17m");
//        xinxi.put("LT1013液位指示","0.29m");
//        xinxi.put("LT1012平均温度","4.21℃");
//        xinxi.put("LT1012产品温度","4.16℃");
//
//
//        xinxi1.put("罐的形状类型","内浮顶");
//        xinxi1.put("设备名称","T102汽油罐");
//        xinxi1.put("温度类型","常温罐");
//        xinxi1.put("压力类型","常压罐");
//        xinxi1.put("设计压力","1");
//        xinxi1.put("设计温度低限","0");
//        xinxi1.put("设计温度高限","100");
//        xinxi1.put("最高工作压力","1");
//        xinxi1.put("储存介质","汽油");
//        xinxi1.put("介质形态","液态");
//        xinxi1.put("LT1021油罐液位","2.48m");
//        xinxi1.put("LT1023液位指示","0.18m");
//        xinxi1.put("LT1022平均温度","1.77℃");
//        xinxi1.put("LT1021产品温度","3.95℃");
//
//        xinxi2.put("罐的形状类型","内浮顶");
//        xinxi2.put("设备名称","T103汽油罐");
//        xinxi2.put("温度类型","常温罐");
//        xinxi2.put("压力类型","常压罐");
//        xinxi2.put("设计压力","1");
//        xinxi2.put("设计温度低限","0");
//        xinxi2.put("设计温度高限","100");
//        xinxi2.put("最高工作压力","1");
//        xinxi2.put("储存介质","汽油");
//        xinxi2.put("介质形态","液态");
//        xinxi2.put("LT1031油罐液位","1.21m");
//        xinxi2.put("LT1033液位指示","4.11m");
//        xinxi2.put("LT1032平均温度","3.48℃");
//        xinxi2.put("LT1031产品温度","3.37℃");
//
//
//        xinxi3.put("罐的形状类型","内浮顶");
//        xinxi3.put("设备名称","T104汽油罐");
//        xinxi3.put("温度类型","常温罐");
//        xinxi3.put("压力类型","常压罐");
//        xinxi3.put("设计压力","1");
//        xinxi3.put("设计温度低限","0");
//        xinxi3.put("设计温度高限","100");
//        xinxi3.put("最高工作压力","1");
//        xinxi3.put("储存介质","汽油");
//        xinxi3.put("介质形态","液态");
//        xinxi3.put("LT1041油罐液位","1.71m");
//        xinxi3.put("LT1043液位指示","4.92m");
//        xinxi3.put("LT1042平均温度","3.41℃");
//        xinxi3.put("LT1041产品温度","4.82℃");
//
//
//        xinxi4.put("罐的形状类型","内浮顶");
//        xinxi4.put("设备名称","T105汽油罐");
//        xinxi4.put("温度类型","常温罐");
//        xinxi4.put("压力类型","常压罐");
//        xinxi4.put("设计压力","1");
//        xinxi4.put("设计温度低限","0");
//        xinxi4.put("设计温度高限","100");
//        xinxi4.put("最高工作压力","1");
//        xinxi4.put("储存介质","汽油");
//        xinxi4.put("介质形态","液态");
//        xinxi4.put("LT1051油罐液位","1.78m");
//        xinxi4.put("LT1053液位指示","4.27m");
//        xinxi4.put("LT1052平均温度","3.48℃");
//        xinxi4.put("LT1051产品温度","2.37℃");
//
//
//        xinxi5.put("罐的形状类型","内浮顶");
//        xinxi5.put("设备名称","T106汽油罐");
//        xinxi5.put("温度类型","常温罐");
//        xinxi5.put("压力类型","常压罐");
//        xinxi5.put("设计压力","1");
//        xinxi5.put("设计温度低限","0");
//        xinxi5.put("设计温度高限","100");
//        xinxi5.put("最高工作压力","1");
//        xinxi5.put("储存介质","汽油");
//        xinxi5.put("介质形态","液态");
//        xinxi5.put("LT1061油罐液位","1.89m");
//        xinxi5.put("LT1063液位指示","3.92m");
//        xinxi5.put("LT1062平均温度","2.41℃");
//        xinxi5.put("LT1061产品温度","3.82℃");
//
//
//        Array.add(xinxi);
//        Array.add(xinxi1);
//        Array.add(xinxi2);
//        Array.add(xinxi3);
//        Array.add(xinxi4);
//        Array.add(xinxi5);
//        json.put("Array",Array);
//        jsonObject.put("param",json);
////        WebSocketTest.sendInfo(jsonObject.toJSONString(), "connect");
        JSONObject jsonObject_one = new JSONObject();
        jsonObject_one.put("instruction","resetpoi");
        WebSocketTest.sendInfo(jsonObject_one.toJSONString(), "connect");

        JSONObject jsonObject2 = new JSONObject();
        JSONObject json2 = new JSONObject();
        jsonObject2.put("instruction","showpoi");
        json2.put("showtype","group");
        json2.put("poigroup","guanqu");
        json2.put("poitype","guanqu");
        jsonObject2.put("param",json2);
        WebSocketTest.sendInfo(jsonObject2.toJSONString(), "connect");

        JSONObject jsonObject3 = new JSONObject();
        JSONObject json3 = new JSONObject();
        jsonObject3.put("instruction","showpoi");
        json3.put("showtype","group");
        json3.put("poigroup","youqihuishou");
        json3.put("poitype","youqihuishou");
        jsonObject3.put("param",json3);
        WebSocketTest.sendInfo(jsonObject3.toJSONString(), "connect");

        JSONObject jsonObject4 = new JSONObject();
        JSONObject json4 = new JSONObject();
        jsonObject4.put("instruction","showpoi");
        json4.put("showtype","group");
        json4.put("poigroup","tiaojieguan");
        json4.put("poitype","tiaojieguan");
        jsonObject4.put("param",json4);
        WebSocketTest.sendInfo(jsonObject4.toJSONString(), "connect");
    }
}
